#include <iostream>
#include <cstring>
using namespace std;

void merge(int *a, int *b, int m, int n, int *result)
{
    int count_a = 0; // 记录已经取出了多少个a中的元素
    int count_b = 0; // 记录已经取出了多少个b中的元素
    while (count_a < m && count_b < n)
    {
        if (a[count_a] < b[count_b])
        {
            result[count_a + count_b] = a[count_a];
            count_a++;
        }
        else
        {
            result[count_a + count_b] = b[count_b];
            count_b++;
        }
        }
    while (count_a < m)
    {
        result[count_a + count_b] = a[count_a];
        count_a++;
    }
    while (count_b < n)
    {
        result[count_a + count_b] = b[count_b];
        count_b++;
    }
}

int main()
{
    int m, n;
    cin >> m;
    int *a = new int[m];
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    cin >> n;
    int *b = new int[n];
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    int *result = new int[m + n];
    merge(a, b, m, n, result);
    for (int i = 0; i < m + n; i++)
    {
        cout << result[i] << " ";
    }
    cout << endl;
    delete[] a;
    delete[] b;
    delete[] result;
    return 0;
}